
import java.util.Deque;
import java.util.LinkedList;

/**
 * @author LKQ
 * @date 2021/12/12 14:43
 * @description
 */
public class Solution {
    public static void main(String[] args) {
        MinStack obj = new MinStack();
        obj.push(2147483646);
        obj.push(2147483646);
        obj.push(2147483647);
        int top = obj.top();
        obj.pop();
        int min = obj.getMin();
        obj.pop();
        min = obj.getMin();
        obj.pop();
        obj.push(2147483647);
        top = obj.top();
        min = obj.getMin();
        obj.push(-2147483648);
        top = obj.top();
        obj.pop();
        min = obj.getMin();
    }
}

class MinStack{
    Deque<Integer> xStack;
    Deque<Integer> minStack;

    public MinStack() {
        xStack = new LinkedList<Integer>();
        minStack = new LinkedList<Integer>();
        minStack.push(Integer.MAX_VALUE);
    }

    public void push(int x) {
        xStack.push(x);
        minStack.push(Math.min(minStack.peek(), x));
    }

    public void pop() {
        xStack.pop();
        minStack.pop();
    }

    public int top() {
        return xStack.peek();
    }

    public int getMin() {
        return minStack.peek();
    }

}